/*
 * Created on2022/6/11 18:22
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.yzbdl.lanius.core.plugins.metastore;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import javax.persistence.*;

import org.pentaho.di.i18n.BaseMessages;
import org.yzbdl.lanius.core.metastore.BaseEntity;

/**
 * 核心对象树分类信息
 *
 * @author hs@yzbdl.ac.cn
 * @version 1.0
 * @date 2019/6/11 18:22
 */
@Entity
@Table(name = "ldr_classification")
public class LdrClassificationEntity extends BaseEntity {
    private static String pkg = "org.pentaho.di.ui.spoon";
    public static final String COMMONLY_NAME = BaseMessages.getString(pkg, "Classification.Name.Commonly");
    public static final String DEFAULT_NAME = BaseMessages.getString(pkg, "Classification.Name.Default");
    // public static final String MARKET_NAME = BaseMessages.getString(pkg, "Classification.Name.Market");
    public static final Integer COMMONLY_SORT = 1;
    public static final Integer DEFAULT_SORT = 9998;
    // public static final Integer MARKET_SORT = 9999;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    protected Integer id;

    // /**
    // * 功能类别, 参照 org.pentaho.di.core.plugins.metastore.FuncType
    // */
    // @Column(name="func_type")
    // private Integer funcType;

    /**
     * 插件类别, 记录PluginType类的全名
     */
    @Column(name = "plugin_type_class")
    private String pluginTypeClass;

    /**
     * 逻辑类别, 参照 org.yzbdl.lanius.core.plugins.metastore.LogicType
     */
    @Column(name = "logic_type")
    private Integer logicType;

    /**
     * 名称
     */
    @Column(name = "name")
    private String name;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime = new Date();

    /**
     * 排序号
     */
    @Column(name = "sort_num")
    private Integer sortNum;

    /**
     * 是否展开
     */
    @Column(name = "expanded")
    private Boolean expanded = false;

    /**
     * 分组信息
     */
    @Transient
    private List<LdrCategoryEntity> categoryEntities = new ArrayList<>();

    /**
     * 插件信息
     */
    @Transient
    private List<LdrPluginEntity> pluginEntities = new ArrayList<>();

    public LdrClassificationEntity() {}

    public LdrClassificationEntity(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    // public Integer getFuncType() {
    // return funcType;
    // }
    //
    // public void setFuncType(Integer funcType) {
    // this.funcType = funcType;
    // }

    public String getPluginTypeClass() {
        return pluginTypeClass;
    }

    public void setPluginTypeClass(String pluginTypeClass) {
        this.pluginTypeClass = pluginTypeClass;
    }

    public Integer getLogicType() {
        return logicType;
    }

    public void setLogicType(Integer logicType) {
        this.logicType = logicType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getSortNum() {
        return sortNum;
    }

    public void setSortNum(Integer sortNum) {
        this.sortNum = sortNum;
    }

    public List<LdrCategoryEntity> getCategoryEntities() {
        return categoryEntities;
    }

    public void setCategoryEntities(List<LdrCategoryEntity> categoryEntities) {
        this.categoryEntities = categoryEntities;
    }

    public List<LdrPluginEntity> getPluginEntities() {
        return pluginEntities;
    }

    public void setPluginEntities(List<LdrPluginEntity> pluginEntities) {
        this.pluginEntities = pluginEntities;
    }

    public Boolean getExpanded() {
        return expanded;
    }

    public void setExpanded(Boolean expanded) {
        this.expanded = expanded;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        LdrClassificationEntity entity = (LdrClassificationEntity)o;
        return Objects.equals(id, entity.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
